﻿<!DOCTYPE html>
<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.bean.*,com.newcrm.util.*,java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> customerCategorys = companyInfo.customerCategorys;
  List<Map<String, Object>> taskCategory = companyInfo.taskCategorys;
  List<Map<String, Object>> dealCategorys = companyInfo.dealCategorys;
  List<User> users = companyInfo.users;
%>
    <script>
      var contextPath = "<%=request.getContextPath()%>";
      var pageSize = <%=Const.PAGE_SIZE%>;
      var visible_person = "<%=Const.VISIBLE_PERSON%>";
      var visible_group = "<%=Const.VISIBLE_GROUP%>";
      var visible_everyone = "<%=Const.VISIBLE_EVERYONE%>";
      var visible_share_owner = "<%=Const.VISIBLE_SHARE_OWNER%>";
      var visible_share_other = "<%=Const.VISIBLE_SHARE_OTHER%>";

      var loginUserId = '<%=user.userId%>';

      // 员工
      var allUsers = new Array();
      <%if (users != null) {
          for (User u:users) { %>
      allUsers.push({id:"<%=u.userId%>",name:"<%=Util.UEncode(u.name)%>"});
      <%  }
        } %>

      // 客户分类
      var customerCategorys = new Array();
      <%if (customerCategorys != null) {
          for (Map<String, Object> category:customerCategorys) {
            String color = (String) category.get("Color");
            if (color == null || color.trim().length() == 0) {
              color = "000000";
            }%>
      customerCategorys.push({id:"<%=category.get("CategoryId")%>",name:"<%=Util.UEncode((String)category.get("CategoryName"))%>", color:"<%=color%>"});
        <%}
      } %>

      // 销售机会分类
      var dealCategorys = new Array();
      <%if (dealCategorys != null) {
          for (Map<String, Object> category:dealCategorys) {
            String color = (String) category.get("Color");
            if (color == null || color.trim().length() == 0) {
              color = "000000";
            }%>
      dealCategorys.push({id:"<%=category.get("DealCategoryId")%>",name:"<%=Util.UEncode((String)category.get("DealCategoryName"))%>", color:"<%=color%>"});
        <%}
      } %>

      var allTaskCategory = new Array();
      <%if (taskCategory != null) {
          for (Map<String, Object> category:taskCategory) {
            String color = (String) category.get("Color");
            if (color == null || color.trim().length() == 0) {
              color = "000000";
            }
          %>
      allTaskCategory.push({id:"<%=category.get("TaskCategoryId")%>",name:"<%=Util.UEncode((String)category.get("TaskCategoryName"))%>", color:"<%=color%>"});
      <% }} %>

      customerParams.PageSize = pageSize;
      customerParams.Visible = visible_person;
      customerParams.PermissionsId = loginUserId;
      customerParams.GroupId = "0";
    </script>